#ifndef COLLISIONHELPER_H
#define COLLISIONHELPER_H

namespace StompedReality {

namespace Collision {

//! \brief	Rectangle A contains rectangle B test.
//!			Any type with a GetCenter() and GetHalfSize() method is rectangle (axis aligned).
//!			Compares Top-Left A < Top-Left B and Bottom-Right A > Bottom-Right B.
//! \param	rectA	Rectangle A.
//! \param	rectB	Rectangle B.
//! \return	ture if rectA contains rectB otherwise false.
template <typename RECT_A, typename RECT_B>
static bool RectContainsRect ( RECT_A rectA, RECT_B rectB )
{
  StompedReality::Math::Vector2 tempA = rectA.GetCenter ( ) - rectA.GetHalfSize ( );
  StompedReality::Math::Vector2 tempB = rectB.GetCenter ( ) - rectB.GetHalfSize ( );

  if ( tempA.GetX ( ) > tempB.GetX ( ) || tempA.GetY ( ) > tempB.GetY ( ) )
    return false;

  tempA = rectA.GetCenter( ) + rectA.GetHalfSize( );
  tempB = rectB.GetCenter( ) + rectB.GetHalfSize( );

  if ( tempA.GetX ( ) < tempB.GetX ( ) || tempA.GetY ( ) < tempB.GetY ( ) )
    return false;

  return true;
}

//! \brief	Rectangle A contains point B test.
//!			Any type with a GetCenter() and GetHalfSize() method is a rectangle.
//!			Any type with a GetX() and GetY() method is a point (axis aligned).
//!			Compares Top-Left A < Point B and Bottom-Right A > Point B.
//! \param	rect	Rectangle.
//! \param	point	Point.
//! \return	ture if rectangle contains the point otherwise false.
template <typename RECT, typename POINT>
static bool RectContainsPoint ( RECT rect, POINT point )
{
  StompedReality::Math::Vector2 tempA = rect.GetCenter ( ) - rect.GetHalfSize ( );

  if ( tempA.GetX ( ) > point.GetX ( ) || tempA.GetY ( ) > point.GetY ( ) )
    return false;

  tempA = rect.GetCenter( ) + rect.GetHalfSize( );

  if ( tempA.GetX ( ) < point.GetX ( ) || tempA.GetY ( ) < point.GetY ( ) )
    return false;

  return true;
}

}

}

#endif // ifndef COLLISIONHELPER_H